<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label for="c-provice_id" class="control-label col-xs-12 col-sm-2">{:__('Province_id')}:</label>
        <div class="col-xs-12 col-sm-8">

            <select id="c-provice" data-rule="required" class="form-control selectpicker" name="row[province_id]"  >
                <option value="0" >--请选择--</option>
                {foreach name="Plist" item="vo"}
                <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('City_id')}:</label>
        <div class="col-xs-12 col-sm-8">
        <input id="c-city" data-rule="required" data-source="project/getpro" class="form-control selectpage"  data-primary-key="Code" data-field="Name"  name="row[city_id]" type="text" value="" >
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
        <div class="col-xs-12 col-sm-8">
        <input id="c-area" data-rule="required" data-source="project/getcity" class="form-control selectpage"  data-primary-key="Code" data-field="Name" name="row[area_id]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address" class="form-control" name="row[address]" type="text">
        </div>
    </div>
    <div class="form-group">
        <label for="c-admin_id" class="control-label col-xs-12 col-sm-2">{:__('Admin_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-admin_id" data-rule="required" class="form-control selectpicker" name="row[admin_id]"  >
                <option value="0" >--请选择--</option>
                {foreach name="admin_list" item="vo"}
                <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Start_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-start_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[start_time]" type="text" value="{:date('Y-m-d')}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('End_time')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-end_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-use-current="true" name="row[end_time]" type="text" value="{:date('Y-m-d')}">
        </div>
    </div>
    
    <dl class="fieldlist" data-template="basictpl" data-name="row[basic]">
     <dd>
    <div class="form-group">
      
           
                <label class="control-label col-xs-12 col-sm-2">{:__('图片')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="input-group">
                        <input id="c-img" class="form-control" style="width:100%" size="50" name="row[img]" type="text" value="">
                        <div class="input-group-addon no-border no-padding">
                            <span><button type="button" id="plupload-img" class="btn btn-danger plupload" data-input-id="c-img" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-img"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                            
                        </div>
                        <span class="msg-box n-right" for="c-img"></span>
                    </div>
                    <ul class="row list-inline plupload-preview" id="p-img"></ul>
                </div>
            
            <dd><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> {:__('Append')}</a></dd> 
     </div>
     </dd>
     </dl>
    <script id="basictpl" type="text/html">
        <dd>
            <div class="form-group">
       
            <label class="control-label col-xs-12 col-sm-2">{:__('图片')}:</label>
                <div class="col-xs-12 col-sm-8">
                    <div class="input-group">
                        <input id="c-img<%=index%>" class="form-control" style="width:100%" size="50" name="row[img<%=index%>]" type="text" value="">
                        <div class="input-group-addon no-border no-padding">
                            <span><button type="button" id="plupload-img<%=index%>" class="btn btn-danger plupload" data-input-id="c-img<%=index%>" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-img<%=index%>"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                        </div>
                        <span class="msg-box n-right" for="c-img<%=index%>"></span>
                    </div>
                    <ul class="row list-inline plupload-preview" id="p-img<%=index%>"></ul>
                </div>
               
         </div>
            
        </dd>
    </script>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Info')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-info" class="form-control " rows="5" name="row[info]" cols="50"></textarea>
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
<script>
    $('#c-area_text').on('change',function(){
        var pro = $('#c-provice').val();
        var city = $('#c-city').val();
        var area = $('#c-area').val();
        
        $.post("{:url('project/agent')}",{pro:pro},function(res){
            console.log(res)
            $("#c-pid").empty()
            if(res.code==1){
                var pros = res.info;
                for(var i=0;i < pros.length;i++){
                    $("#c-pid").append('<option value='+ pros[i].id +'>'+pros[i].shop_name+'</option>');
                };
                $("#c-pid").removeAttr('disabled');
            }else{
                $("#c-pid").attr('disabled','disabled');
                $("#c-pid").append('<option value="">'+res.info+'</option>');
            }
        });
    });
    
</script>

